<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="./vue.js"></script>
</head>

<body>
  <div id="app">
    <!-- 显示总价格 -->
    <h2>总价格：{{totalPrice}}</h2>
  </div>

  <script>
    var vm = new Vue({
      el: '#app',
      data: {
        name: 'Taec',
        books: [{
          id: 110,
          name: 'asdfa',
          price: 11
        },
        {
          id: 111,
          name: 'as3a',
          price: 17
        },
        {
          id: 112,
          name: 'a4a',
          price: 61
        }]
      },
      computed: {
        totalPrice: function () {
          let result = 0;
          for (let i = 0; i < this.books.length; i++) {
            result += this.books[i].price;
          }
          return result;
        }
      }
    })
  </script>
</body>

</html>